import request from '@/utils/request'
// import { getToken } from '@/utils/token'

const punlishArticleApi = ({
  draft = false,
  title,
  content,
  cover,
  channel_id
}) => request({
  method: 'post',
  url: '/v1_0/mp/articles',
  //   headers: {
  //     Authorization: `Bearer ${getToken()}`
  //   },
  params: {
    draft
  },
  data: {
    title,
    content,
    cover,
    channel_id
  }
})

// 2.定义获取文章详情的接口
const getArticleDetailAPI = ({ artId }) => {
  return request({
    method: 'get',
    url: `/v1_0/mp/articles/${artId}`

  })
}

// 4.定义编辑文章接口
const updatedArticleAPI = ({ artId, draft = false, title, content, cover, channel_id }) => request({
  method: 'put',
  url: `/v1_0/mp/articles/${artId}`,
  params: {
    draft
  },
  data: {
    artId, draft, title, content, cover, channel_id
  }
})

export { punlishArticleApi, getArticleDetailAPI, updatedArticleAPI }
